<template>
	<view>
		子组件
		<!-- 给父类传值 -->
		<!-- <button @click="$emit('add',Math.random())">按钮</button> -->
		<button @click="onClick">按钮</button>
		<view>----------</view>
		
		<input type="text" @input="onInput"/>
	</view>
</template>

<script setup>
import {ref} from "vue"

// 声明组件可触发的事件add
const emit = defineEmits(["add","change"])
function onClick(){
	// 给父类传值
	emit("add",Math.random())
}

function onInput(e){
	// console.log(e.detail.value)
	emit("change",e.detail.value)
}
</script>

<style lang="scss" scoped>
input{
	height: 40px;
	border: 1px solid #cfcfcf;
}
</style>